package sg.edu.nus.iss.jass.datastore;

import sg.edu.nus.iss.jass.datastore.exception.DataStoreException;

/**
 * <p>Define the operation to support transaction</p>
 * It is including start transaction, commit transaction, roll back transaction
 * @author WANG DAYONG
 *
 */
public interface Transaction {

	/**
	 * <p>Start transaction.</p>
	 * 
	 * @throws DataStoreException
	 * 			If a transaction has been started before, but not commit or rollback.
	 */
	void startTransaction() throws DataStoreException;

	/**
	 * <p>Apply all the data changes to storage that modified in one transaction</p>
	 * 
	 * @throws DataStoreException
	 * 			If error happened when apply all changes
	 */
	void commit() throws DataStoreException;

	/**
	 * <p>Abandon all changes of the transaction, and keep the original state before this transaction.</p>
	 * 
	 * @throws DataStoreException
	 * 			If error happen when apply all changes.
	 */
	void rollback() throws DataStoreException;
}
